package cloud.daodao.storm.security.controller;

import cloud.daodao.storm.common.security.model.secret.*;
import cloud.daodao.storm.security.service.SecretService;
import cloud.daodao.storm.common.security.api.SecretApi;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DaoDao
 */
@RestController
public class SecretController implements SecretApi {

    @Resource
    private SecretService secretService;

    @Override
    public Response<AesData> aesSelect(Request<AesSelect> request) {
        AesData aesData = secretService.aesSelect(request.getParam());
        return new Response<>(aesData);
    }

    @Override
    public Response<AesData> aesUpsert(Request<AesUpsert> request) {
        AesData aesData = secretService.aesUpsert(request.getParam());
        return new Response<>(aesData);
    }

    @Override
    public Response<RsaData> rsaSelect(Request<RsaSelect> request) {
        RsaData rsaData = secretService.rsaSelect(request.getParam());
        return new Response<>(rsaData);
    }

    @Override
    public Response<RsaData> rsaUpsert(Request<RsaUpsert> request) {
        RsaData rsaData = secretService.rsaUpsert(request.getParam());
        return new Response<>(rsaData);
    }

}
